package es.ibm.santillana.mdm.migration;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

import com.ibm.pim.attribute.AttributeInstance;
import com.ibm.pim.catalog.Catalog;
import com.ibm.pim.catalog.item.Item;
import com.ibm.pim.collection.PIMCollection;
import com.ibm.pim.common.ProcessingOptions;
import com.ibm.pim.common.exceptions.PIMAlreadyInTransactionException;
import com.ibm.pim.common.exceptions.PIMInvalidOperationException;
import com.ibm.pim.context.Context;
import com.ibm.pim.context.PIMContextFactory;
import com.ibm.pim.extensionpoints.ImportFunction;
import com.ibm.pim.extensionpoints.ImportFunctionArguments;

import es.ibm.santillana.mdm.common.util.PIMDBConnection;
import es.ibm.santillana.mdm.deployment.DeployEnviroment;

public class ItemCatalogosImport implements ImportFunction {

	@Override
	public void doImport(ImportFunctionArguments arg0) {
		Context ctx = PIMContextFactory.getCurrentContext();
		
		try {
			DeployEnviroment.cargarTemasTransversales(ctx);
		} catch (PIMInvalidOperationException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		
		try {
			DeployEnviroment.cargarNiveles(ctx);
		} catch (PIMInvalidOperationException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		
		
		try {
			DeployEnviroment.cargarSeriesMetodos(ctx);
		} catch (PIMInvalidOperationException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		
		
		
		try {
			DeployEnviroment.cargarCursos(ctx);
		} catch (PIMInvalidOperationException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		
		
		
		try {
			DeployEnviroment.cargarAsignaturas(ctx);
		} catch (PIMInvalidOperationException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
	}
}
